package com.kinggm.config;

import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

/**
 * 配置多数据源
 * */

@Configuration
@MapperScan("com.kinggm.mapper.**")
public class DataSourceConfig {


    @ConfigurationProperties(prefix = "spring.datasource")
    @Bean("dataSourceOne")
    public DataSource getDataSourceOne(){
        return DruidDataSourceBuilder.create().build();
    }




    @ConfigurationProperties(prefix = "db2.spring.datasource")
    @Bean("dataSourceTwo")
    public DataSource getDataSourceTwo(){
        return DruidDataSourceBuilder.create().build();
    }



}
